#include<string>
#include<memory>
#include<functional>
#include<iostream>
#include"EventLoop.hpp"  //处理IO
#include"ServerCal.hpp"   //处理业务


Calculator calculator;

void DefaultOnMessage(const std::shared_ptr<Connection> connection_ptr)
{
    std::cout<<"上层得到了数据:  "<<connection_ptr->Inbuffer()<<std::endl;
    std::string response_str = calculator.Handler(connection_ptr->Inbuffer());
    if(response_str.empty())
    {
        return;
    }
    lg(Debug,"%s",response_str.c_str());
    //response_str发送出去
    connection_ptr->AppendOutBuffer(response_str);
    //connection_ptr->_send_cb(connection_ptr);
    connection_ptr->_tcp_server_ptr->Sender(connection_ptr);

}

int main()
{
    std::unique_ptr<TcpServer> svr(new TcpServer(8080,DefaultOnMessage));
    svr->Init();
    svr->Loop();

    return 0;

}